<%@page import="org.brickred.socialauth.SocialAuthManager"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.brickred.socialauth.AuthProvider"%>
<%@page import="org.brickred.socialauth.util.SocialAuthUtil"%>
<%@page import="java.util.Map"%>
<%@page import="org.brickred.socialauth.Profile"%>
<%@page import="java.util.ArrayList"%>
<%@page import="org.brickred.socialauth.Contact"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
	List<Contact> contactsList = new ArrayList<Contact>();
	
	Profile profile = null;
	SocialAuthManager manager = (SocialAuthManager) session.getAttribute("manager");
	Map<String, String> paramsMap = SocialAuthUtil.getRequestParametersMap(request);
	if(session.getAttribute("contactsList")==null){
		AuthProvider provider = manager.connect(paramsMap);
		profile = provider.getUserProfile();
		contactsList = provider.getContactList();
	}else{
		contactsList = (List<Contact>) session.getAttribute("contactsList");		
	}
	session.setAttribute("contactsList", contactsList);
%>
	<center><a href="index.html">Go to main page</a></center>
	<br>
	<table align="center" border="1">
		<tr></tr>	
		<tr>
			<th align="left">Email Address</th>
		</tr>
	
<%

	if (contactsList != null && contactsList.size() > 0) {
		for (Contact p : contactsList) {
%>
			<tr>
				<td align="left"><%=p.getEmail() %></td>
			</tr>
<%		
			/*if (StringUtils.isEmpty(p.getFirstName())
					&& StringUtils.isEmpty(p.getLastName())) {
				p.setFirstName(p.getDisplayName());
			}*/
		}
	}
%>
	</table>
</body>
</html>